package com.qq.aidoctor.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qq.aidoctor.bean.DoctorSchedule;
import com.qq.aidoctor.service.DoctorScheduleService;
import com.qq.aidoctor.mapper.DoctorScheduleMapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 12948
* @description 针对表【doctor_schedule(医生排班信息表)】的数据库操作Service实现
* @createDate 2025-06-09 10:40:07
*/
@Service
public class DoctorScheduleServiceImpl extends ServiceImpl<DoctorScheduleMapper, DoctorSchedule>
    implements DoctorScheduleService{


    /**
     * 根据 科室、日期、时间段 查询当前有哪些医生有排班且有号可挂
     * @param department
     * @param date
     * @param time
     * @return
     */
    @Override
    public List<DoctorSchedule> listAvailableDoctors(String department, String date, String time) {
        LambdaQueryWrapper<DoctorSchedule> queryWrapper = Wrappers.lambdaQuery(DoctorSchedule.class)
                .eq(DoctorSchedule::getDepartment, department)
                .eq(DoctorSchedule::getDate, date)
                .eq(DoctorSchedule::getTime, time)
                .gt(DoctorSchedule::getAvailableSlots, 0);
        return baseMapper.selectList(queryWrapper);
    }
}




